package mx.com.daycare.view;

import java.util.List;

import javax.ejb.EJB;
import javax.faces.model.ListDataModel;
import mx.com.daycare.entity.Family;

import org.primefaces.model.SelectableDataModel;

public class FamilyDataModel extends ListDataModel<Family> implements SelectableDataModel<Family>{

	public FamilyDataModel(List<Family> data){
		super(data);
	}	
	
	@Override
	public Family getRowData(String key) {
		List<Family> families = (List<Family>)getWrappedData();
		for(Family family : families){
			if(family.getId().toString().equals(key)){
				return family;
			}
		}
		return null;		
	}

	
	public Object getRowKey(Family family) {
		return family.getId();
	}

}
